#pragma once
#include "HashTable.h"
namespace lw
{
	template<class K, class Hash = HashFunc<K>>
	class unordered_set
	{
		struct SetKeyOfT
		{
			const K& operator()(const K& key)
			{
				return key;
			}
		};
	public:
		typedef typename hashbucket::HashTable<K, const K, SetKeyOfT, Hash>::iterator iterator;
		iterator begin()
		{
			return _ht.begin();
		}
		iterator end()
		{
			return _ht.end();
		}
		pair<iterator, bool> insert(const K& key)
		{
			return _ht.Insert(key);
		}
		bool find(const K& key)
		{
			return _ht.Find(key) != end();
		}
		bool erase(const K& key)
		{
			return _ht.Erase(key);
		}
	private:
		hashbucket::HashTable<K, const K, SetKeyOfT, Hash> _ht;
	};

	void TestSet()
	{
		unordered_set<int> s;
		int a[] = { 1, 4, 5, 14, 15, 8, 9 ,19 };
		for (auto e : a)
			s.insert(e);
		for (auto e : s)
		{
			cout << e << endl;
		}
	}
}